package br.unipampa.dados;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author Gabriel Moro
 * @since 15/03/2013
 * @version 1.2
 */
public class DBConection {

    private static final String URL_DATABASE = "jdbc:mysql://localhost:3306/agendaprincipal";
    private static final String USER_BANCO = "root";
    private static final String PASS_BANCO = "thaises2@#/";
    private Connection con;

    public DBConection() throws SQLException {
        conectar();
    }

    private void conectar() throws SQLException {
        try {
            this.con = DriverManager.getConnection(this.URL_DATABASE, this.USER_BANCO, this.PASS_BANCO);
        } catch (SQLException sql) {
            sql.printStackTrace();
        }
    }

    public void encerrarConexao() {
        try {
            if (this.con != null) {
                this.con.close();
            }
        } catch (SQLException sql) {
            sql.printStackTrace();
        }
    }

    public Connection getCon() {
        return con;
    }
}
